﻿<%@ Page Title="Frontdesk" Language="C#" MasterPageFile="~/Views/Shared/FrontdeskEmpty.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<Sendz.WebUI.Models.FormFieldViewModel>>" %>

<asp:Content ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <% using (Ajax.BeginForm(new AjaxOptions { Url = "/Form/Display", UpdateTargetId = "wrapper", OnBegin = "onBegin", InsertionMode = InsertionMode.Replace }))
       { %>
    <% foreach (var field in Model)
       {
           // Render the partial control from the field.ListEnum (aka control name) to avoid any conditional logic in the view
    %>
    <div class="form-field">
        <% Html.RenderPartial(field.ListEnum, field); %>
        <% // Hidden values ////////////////////// %>
        <%: Html.Hidden("formfields.Index", field.FormFieldKey) %>
        <%: Html.Hidden(string.Format("formfields[{0}].FormFieldKey", field.FormFieldKey), field.FormFieldKey) %>
    </div>
    <% }
    %>
    <div class="actions">
        <%: Html.Hidden("FormKey", ViewData["FormKey"]) %>
        <input type="submit" value="Submit" class="button" />
    </div>
    <%
        } %>
</asp:Content>
<asp:Content ContentPlaceHolderID="footer" runat="server">
</asp:Content>
